#include "accountsitemmodel.h"


AccountsItemModel::AccountsItemModel( const QString &_accountJid,
                                      const QString &_accountPasswd,
                                      const QString &_accountIcon,
                                      const bool _accountDefault,
                                      QObject *parent ) :
    ListItem(parent),
    m_jid(_accountJid),
    m_passwd(_accountPasswd),
    m_icon(_accountIcon),
    m_default(_accountDefault)
{
}

void AccountsItemModel::setJid(QString &_accountJid)
{
  if(m_jid != _accountJid) {
    m_jid = _accountJid;
    emit dataChanged();
  }
}

void AccountsItemModel::setPasswd(QString &_accountPasswd)
{
  if(m_passwd != _accountPasswd) {
    m_passwd = _accountPasswd;
    emit dataChanged();
  }
}

void AccountsItemModel::setIcon(QString &_accountIcon)
{
  if(m_icon != _accountIcon) {
    m_icon = _accountIcon;
    emit dataChanged();
  }
}

void AccountsItemModel::setDefault(bool &_accountDefault)
{
  if(m_default != _accountDefault) {
    m_default = _accountDefault;
    emit dataChanged();
  }
}



QHash<int, QByteArray> AccountsItemModel::roleNames() const
{
  QHash<int, QByteArray> names;
  names[accJid] = "accJid";
  names[accPasswd] = "accPasswd";
  names[accIcon] = "accIcon";
  names[accDefault] = "accDefault";
  return names;
}

QVariant AccountsItemModel::data(int role) const
{
  switch(role) {
  case accJid:
    return jid();
  case accPasswd:
    return passwd();
  case accIcon:
    return icon();
  case accDefault:
    return isDefault();
  default:
    return QVariant();
  }
}
